<template>
	<view class="content">
		<uni-list v-for="(item,index) in news" :key="index">
			<uni-list-item
					:title="item.title" 
					:note="item.summary" 
					:thumb="item.cover"
					thumb-size="lg" 
					@click="goToInfo(item)"
					:rightText="item.author_name">
			</uni-list-item>
		</uni-list>
		<loadding
			:show="showPageLoadding" 
			@onReloadClick='reloadHd'
		>
		</loadding>
	</view>
</template>

<script>
	import loadding from "@/components/lib/page-loadding.vue";
	export default {
		data() {
			return {
				news:[],
				showPageLoadding:true
			}
		},
		components:{
			loadding
		},
		onLoad() {
			uni.request({
				url: 'https://unidemo.dcloud.net.cn/api/news',
				method: 'GET',
				data: {},
				success: res => {
					console.log(res)
					this.news=res.data
					this.showPageLoadding = false;
				},
				fail: () => {},
				complete: () => {}
			});
		},
		methods: {
			goToInfo(item){
				var newsid=item.post_id
				// console.log(newsid)
				uni.navigateTo({
					url: '../info/info?newsId='+newsid
				});
			}
		}
	}
</script>

<style>
	
</style>
